package mapmaker.thread;

import java.util.TimerTask;

import mapmaker.log.Log;
import mapmaker.map.EnvironmentMap;

public class ThreadSaveMap extends TimerTask{

	private static final String LOG_TAG = ThreadSaveMap.class.getSimpleName();
	private EnvironmentMap _map;
	private String _fileName;
	
	public ThreadSaveMap(EnvironmentMap map, String fileName){
		_map = map;
		_fileName = fileName;
	}
	
	@Override
	public void run() {
		Log.i(LOG_TAG, "Saving map to " + _fileName);
		long start = System.currentTimeMillis();
		_map.generateMapImage(_fileName);
		long end = System.currentTimeMillis();
		Log.i(LOG_TAG, "Map saved to " + _fileName + " in : " + (end - start) / 1000.0 + "s");
	}

}
